<%@ page language="java" import="com.eva.framework.dbpool.DBShell,
	java.util.*,
	java.util.regex.Matcher,
	java.util.regex.Pattern,
	com.eva.epc.common.util.CommonUtils" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String idOrMail = request.getParameter("loginName");
String verificationCode = request.getParameter("verificationCode");

DBShell db = new DBShell();

if(CommonUtils.isStringEmpty(idOrMail) || CommonUtils.isStringEmpty(verificationCode))
{
	//请求信息不完整
	response.setStatus(301);
	response.setHeader("Location",basePath+"view/error.jsp?code=-1");
	response.setHeader("Connection", "close");
}
else
{
	String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
	Pattern p = Pattern.compile(str);
	Matcher m = p.matcher(idOrMail);
	
	String sql = "";
	if(m.matches())
		sql= "SELECT user_uid FROM g_users where del_flag = 0 and user_mail='" + idOrMail + "'";
	else
		sql= "SELECT user_uid FROM g_users where del_flag = 0 and user_uid='" + idOrMail + "'";
	String user_uid = db.querySingleItem(sql);
	
	if(user_uid == null)
	{
		//请求信息不完整,不存在用户
		response.setStatus(301);
		response.setHeader("Location",basePath+"view/error.jsp?code=-2");
		response.setHeader("Connection", "close");
	}
	else
	{
		response.setStatus(301);
		response.setHeader("Location",basePath+"view/forget.jsp?loginName=" + idOrMail + "&verificationCode=" + verificationCode);
		response.setHeader("Connection", "close");
	}
}
%>